<?php

namespace app\admin\controller;
use think\Config;
use think\Controller;
use think\Session;
use think\Db;

class Allow extends Controller{
	public function _initialize(){
		//检测用户是否登陆
		if(!Session::get('islogin')){
			$this->error("请先登录","/adminlogin/login");
		}

		//检测权限
		$request = request();
		//获取用户访问模块的控制器和方法
		$controller = strtolower($request->controller());
		$action = strtolower($request->action());

		//获取当前用户权限信息		
		$nodelist = Session::get("nodelist");
		// var_dump($nodelist);die();
		
		if(empty($nodelist[$controller])||!in_array($action,$nodelist[$controller])){
			$this->error("你没有权限访问这个模块,请联系超级管理员","/adminindex/index");
		}


	}
}
